package com.aube.base;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by hill on 10/24.
 */
public class BadgeBg extends View {

    private Paint mPaint;

    public BadgeBg(Context context) {
        this(context, null);
    }
    public BadgeBg(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
    public BadgeBg(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mPaint = new Paint();
        mPaint.setColor(Color.RED);
        mPaint.setAntiAlias(true);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int width = getMeasuredWidth();
        int height = getMeasuredHeight();

        //画圆角矩形
        mPaint.setStyle(Paint.Style.FILL);
        RectF oval = new RectF(0, 0, width, height);
        canvas.drawRoundRect(oval, height/2, height/2, mPaint);

    }

}
